package tms.view;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.border.EmptyBorder;

import tms.Helper;
import tms.controler.ConfirmController;

public class ConfirmView extends JPanel {
    private static final long serialVersionUID = 1L;
    private JPanel contentPane;
    private JTable tblResrCharges;
    private JLabel lblTicketNum;
    private JLabel lblDepDepFlight;
    private JLabel lblDetailDepFlight;
    private JLabel lblDepReFlight;
    private JLabel lblArriReFlight;
    private JLabel lblArriDepFlight;
    private JLabel lblDetiailReFlight;
    private JLabel lblTitle;
    private JLabel lblFName;
    private JLabel lblAdd;
    private JLabel lblCountry;
    private JLabel lblEmail;
    private JLabel lblLName;
    private JLabel lblDOB;
    private JLabel lblMobile;
    private JLabel lblNameBooker;
    private JLabel lblEmailBooker;
    private JLabel lblPhoneBooker;
    private JPanel pnlBooker;
    private JLabel lblSeat;

    public ConfirmView(final ConfirmController controller) {
        setBounds(400, 0, 600, 740);
        setLayout(new BorderLayout());
        setPreferredSize(new Dimension(600, 740));
        contentPane = new JPanel();
        contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
        contentPane.setLayout(null);
        contentPane.setAutoscrolls(true);
        add(contentPane, BorderLayout.CENTER);
        Tools.addJLabel(contentPane, "Confirm Reservation Information", Tools.TAHOMA_BOLD_14, 10, 11, 265, 14);
        Tools.addJLabel(contentPane, "Ticket Number:", Tools.TAHOMA_BOLD_12, 20, 42, 117, 14);
        lblTicketNum = Tools.addJLabel(contentPane, "TicketNum", Tools.TAHOMA_BOLD_12, 140, 42, 500, 14);
        Tools.addJLabel(contentPane, "Departure Flight", Tools.TAHOMA_BOLD_13, 20, 82, 147, 14);
        Tools.addJLabel(contentPane, "Departs", Tools.TAHOMA_BOLD_11, 30, 107, 46, 14);
        Tools.addJLabel(contentPane, "Arrivals", Tools.TAHOMA_BOLD_11, 172, 107, 46, 14);
        Tools.addJLabel(contentPane, "Flight Detail", Tools.TAHOMA_BOLD_11, 303, 107, 107, 14);
        lblDepDepFlight = Tools.addJLabel(contentPane, "NA", null, 23, 122, 120, 40);
        lblArriDepFlight = Tools.addJLabel(contentPane, "NA", null, 166, 122, 120, 40);
        lblDetailDepFlight = Tools.addJLabel(contentPane, "NA", null, 303, 122, 66, 40);
        Tools.addJLabel(contentPane, "Return Flight", Tools.TAHOMA_BOLD_13, 20, 170, 147, 14);
        Tools.addJLabel(contentPane, "Departs", Tools.TAHOMA_BOLD_11, 30, 195, 46, 14);
        lblArriReFlight = Tools.addJLabel(contentPane, "NA", null, 166, 210, 120, 40);
        lblDepReFlight = Tools.addJLabel(contentPane, "NA", null, 23, 210, 120, 40);
        Tools.addJLabel(contentPane, "Arrivals", Tools.TAHOMA_BOLD_11, 172, 195, 46, 14);
        lblDetiailReFlight = Tools.addJLabel(contentPane, "NA", null, 303, 210, 66, 40);
        Tools.addJLabel(contentPane, "Flight Detail", Tools.TAHOMA_BOLD_11, 303, 195, 107, 14);
        Tools.addJLabel(contentPane, "Reservation Charges", Tools.TAHOMA_BOLD_13, 20, 261, 147, 14);

        // insert table new with data
        JScrollPane scrollPane = new JScrollPane();

        scrollPane.setBounds(14, 287, 515, 110);
        contentPane.add(scrollPane);
        tblResrCharges = controller.loadData();
        tblResrCharges.getColumnModel().getColumn(0).setPreferredWidth(160);
        scrollPane.setViewportView(tblResrCharges);
        Tools.addJLabel(contentPane, "Title:", null, 30, 446, 46, 14);
        Tools.addJLabel(contentPane, "First Name:", null, 30, 471, 72, 14);
        Tools.addJLabel(contentPane, "Primary Reservation Contact Information",
                Tools.TAHOMA_BOLD_13, 20, 421, 331, 14);
        Tools.addJLabel(contentPane, "Title", null, 30, 446, 46, 14);
        Tools.addJLabel(contentPane, "First Name:", null, 30, 471, 72, 14);
        Tools.addJLabel(contentPane, "Address:", null, 30, 496, 59, 14);
        Tools.addJLabel(contentPane, "Country:", null, 30, 521, 59, 14);
        Tools.addJLabel(contentPane, "Email:", null, 30, 546, 59, 14);
        Tools.addJLabel(contentPane, "Last Name:", null, 303, 471, 72, 14);
        Tools.addJLabel(contentPane, "Date of Birth:", null, 303, 521, 83, 14);
        Tools.addJLabel(contentPane, "Mobile Number:", null, 303, 546, 102, 14);
        lblTitle = Tools.addJLabel(contentPane, "NA", null, 59, 446, 17, 14);
        lblFName = Tools.addJLabel(contentPane, "NA", null, 112, 471, 150, 14);
        lblAdd = Tools.addJLabel(contentPane, "NA", null, 87, 496, 150, 14);
        lblCountry = Tools.addJLabel(contentPane, "NA", null, 87, 521, 150, 14);
        lblEmail = Tools.addJLabel(contentPane, "NA", null, 87, 546, 150, 14);
        lblLName = Tools.addJLabel(contentPane, "NA", null, 393, 471, 150, 14);
        lblDOB = Tools.addJLabel(contentPane, "NA", null, 396, 521, 150, 14);
        lblMobile = Tools.addJLabel(contentPane, "NA", null, 411, 546, 150, 14);
        Tools.addJButton(contentPane, "Finish",Tools.TAHOMA_BOLD_12, 270, 660, 127, 31,
                new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                controller.finishBooking();
            }
        }, null);
        pnlBooker = new JPanel();
        pnlBooker.setBounds(14, 595, 548, 62);
        contentPane.add(pnlBooker);
        pnlBooker.setLayout(null);
        Tools.addJLabel(pnlBooker, "Information of booker:", Tools.TAHOMA_BOLD_13, 0, 11, 156, 14);
        Tools.addJLabel(pnlBooker, "Name:", null, 0, 36, 46, 14);
        lblNameBooker = Tools.addJLabel(pnlBooker, "NA", null, 45, 36, 149, 14);
        Tools.addJLabel(pnlBooker, "Phone:", null, 204, 36, 46, 14);
        lblPhoneBooker = Tools.addJLabel(pnlBooker, "NA", null, 249, 36, 84, 14);
        Tools.addJLabel(pnlBooker, "Email:", null, 343, 36, 46, 14);
        lblEmailBooker = Tools.addJLabel(pnlBooker, "NA", null, 399, 36, 149, 14);

        pnlBooker.setVisible(false);
    }

    public void setDepDepFlight(String depDepFlight) {
        lblDepDepFlight.setText(depDepFlight);
    }

    public void setArriDepFlight(String arrDepFlight) {
        lblArriDepFlight.setText(arrDepFlight);
    }

    public void setDetailDepFlight(String depFlightDetail) {
        lblDetailDepFlight.setText(depFlightDetail);
    }

    public void setDepReFlightt(String depReFlight) {
        lblDepReFlight.setText(depReFlight);
    }

    public void setArriReFlight(String arrReFlight) {
        lblArriReFlight.setText(arrReFlight);
    }

    public void setDetailReFlight(String reFlightDetail) {
        lblDetiailReFlight.setText(reFlightDetail);
    }

    public void setTicketNumber(String ticketNumber) {
        lblTicketNum.setText(ticketNumber);
    }

    public void setTitlePass(String title) {
        lblTitle.setText(title);
    }

    public void setfName(String fName) {
        lblFName.setText(fName);
    }

    public void setlName(String lName) {
        lblLName.setText(lName);
    }

    public void setAdd(String add) {
        lblAdd.setText(add);
    }

    public void setCountry(String country) {
        lblCountry.setText(country);
    }

    public void setEmail(String email) {
        lblEmail.setText(email);
    }

    public void setMobile(String mobile) {
        lblMobile.setText(mobile);
    }

    public void setDOB(java.util.Date date) {
        String tmp = Helper.dateToString(date, Tools.DATE_FORMAT_NO_TIME_2);

        lblDOB.setText(tmp);
    }

    public void setEmailN2(String emailN2) {
        lblEmailBooker.setText(emailN2);
    }

    public void setMobileN2(String mobileN2) {
        lblPhoneBooker.setText(mobileN2);
    }

    public void setNameN2(String nameN2) {
        lblNameBooker.setText(nameN2);
    }

    public void setVisibleBooker(boolean bol) {
        pnlBooker.setVisible(bol);
    }

    public void setSeatNumber(int seatNumber) {
        String tmp = Integer.toString(seatNumber);

        lblSeat.setText(tmp);
    }
}